<!DOCTYPE html>
<html  xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>发票管理</title>
	<link th:include="common/header::copy"/>
	<script type="text/javascript">

	function formatOp(val,row,index){
		var str = '';
		if ($("#update").length > 0) {
			str += $.formatString('<a href="javascript:void(0)" class="role-easyui-linkbutton-edit"  onclick="editFun(\'{0}\');" >开票</a>', index);
		}
		return str;
	}

	function search(){
		$("#dg").datagrid('load',{
			"taxNo":$("#s_taxNo").val()
		});
	}
	
	function resetValue(){
		$("#id").val("");
		$("#taxNo").val("")
		$("#payMoney").val("")
		$("#invoced").val("")
	}

	// function savereceipt(){
	// 	$("#fmr").form("submit",{
	// 		url:'/fin/invoice/receipt',
	// 		method:'post',
	// 		onSubmit:function(){
	// 			return $(this).form("validate");
	// 		},
	// 		success:function(result){
	// 			var result=eval('('+result+')');
	// 			if(result.success){
	// 				$.messager.alert("系统提示","保存成功！");
	// 				resetValue();
	// 				$("#dlgr").dialog("close");
	// 				$("#dg").datagrid("reload");
	// 			}else{
	// 				$.messager.alert("系统提示",result.Info);
	// 			}
	// 		}
	// 	});
	// }

	function editFun(index){
		$("#dg").datagrid('selectRow',index);
		var row =$("#dg").datagrid('getSelected');
		if(row) {
			$("#dlg").dialog("open").dialog("setTitle","开票信息");
			$("#fm").form("load",row);
		}
	}
	// function openreceiptModifyDialog(index){
	// 	$("#dg").datagrid('selectRow',index);
	// 	var row =$("#dg").datagrid('getSelected');
	// 	if(row) {
	// 		$("#dlgr").dialog("open").dialog("setTitle","回执信息");
	// 		$("#fmr").form("load",row);
	// 	}
	// }
	//
	// function paymentType(val){
	// 	if(val==0){
	// 		return "未支付";
	// 	}else if(val==1){
	// 		return "已支付";
	// 	}
	// }
	function billType(val){
		if(val==0){
			return "未开票";
		}else if(val==1){
			return "开票中";
		}else if(val==2) {
			return "已开票"
		}
	}
	
</script>
</head>
<body style="margin: 1px">
<shiro:hasPermission name="fin:invoice:save">
	<input type="hidden" id="update"/>
</shiro:hasPermission>
	<table id="dg" title="发票管理" class="easyui-datagrid"
	fitColumns="true" pagination="true" rownumbers="true" singleSelect="true"
	url="/fin/invoice/list" fit="true" toolbar="#tb" method="post" striped="true">
		<thead>
			<th field="id" width="20" align="center" hidden="true">编号</th>
			<th field="taxNo" width="150" align="center">票据单号</th>
			<th field="payMoney" width="150" align="center">应付款</th>
			<th field="invoiced" width="150" align="center" formatter="billType">开票状态</th>
			<th field="op" width="100" align="center" formatter="formatOp">操作</th>
		</thead>
	</table>
	<div id="tb">
		<div style="display: inline-block;margin-left: 15px ">
			票据单号：<input type="text" id="s_taxNo" size="20" />&nbsp;
			<a href="javascript:search()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
			<a href="javascript:" class="easyui-linkbutton"data-options="plain:true"
				onclick="$('#dg').datagrid('toExcel','invoice.xls')">导出</a>
		</div>
	</div>

	<div id="dlg" class="easyui-dialog" style="width: 450px;height: 450px;padding: 20px 50px"
		 closed="true" buttons="#dlg-buttons" data-options="onClose:function(){resetValue()}">
		<form id="fm" method="post">
			<input type="hidden" id="id" name="id">
			<input type="hidden" id="applyid" name="applyid">
			<table cellspacing="8px">
				<tr>
					<td>票据单号：</td>
					<td>
						<input type="text" id="taxNo" name="taxNo"  class="easyui-validatebox"  style="width: 250px"/>
					</td>
				</tr>

				<tr>
					<td>应付款：</td>
					<td>
						<input type="text" id="payMoney" name="payMoney"  class="easyui-validatebox"  style="width: 250px"/>
					</td>
				</tr>
			</table>
		</form>
	</div>
	<div id="dlg-buttons">
		<a href="javascript:save('/fin/invoice/save','开票成功')" class="easyui-linkbutton" iconCls="icon-ok" >开票</a>
		<a href="javascript:closeDialog('#dlg')" class="easyui-linkbutton" iconCls="icon-cancel" >关闭</a>
	</div>
</body>
</html>